package demo.java.lang.management.vo;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * @author mandy.hu
 * 
 */
public class XmlySpan implements Serializable {

	private static final long serialVersionUID = 4780059355572215305L;

	private String appName;
	private String traceId;
	private String spanId;
	private String parentId;
	private String spanName;
	private String serviceId;
	private String url;
	
	private String viewId;
	private String seqId;
	private String ip;

	private DeviceInfo deviceInfo ;

	private Location location; // optional，不一定有，打开定位才有
	private String xmlyId;
	private String userId;

	private EventType eventType;// required
	private String personalType;
	private String personalApp;
	private String monitorId;
	private String monitorPId;
	
	private String detectAttrApp;
	private String detectAttrServiceId;
	private String detectAttrHost;

	private Map<String, String> props; // optional
	private long ts; // required，收到数据时间，collector离线数据要区分
	private String status;
	private List<Annotation> annotations;
	private SpanType spanType;
	private List<BinaryAnnotation> binaryAnnotations;
	private Boolean isRowData = false;
	private Boolean isSample = true;
	private Map<String, String> abTestMap;
	private Map<String, Object> clickMap;

    public XmlySpan() {
//        props.put(ClientConstants.X_B3_SOURCE_TYPE, ClientConstants.X_B3_SOURCE_TYPE_JAVA_VALUE);
//        props.put(ClientConstants.X_B3_RESULT_SPAN, "true");
    }

    public void addBinaryAnnotation(BinaryAnnotation a) {
        if (binaryAnnotations ==null) {
            binaryAnnotations = new ArrayList<BinaryAnnotation>();
        }
		binaryAnnotations.add(a);
	}

	public String getAppName() {

		return appName;
	}

	public void setAppName(String appName) {

		this.appName = appName;
	}

	/**
	 * @return the spanName
	 */
	public String getSpanName() {

		return spanName;
	}

	/**
	 * @param spanName
	 *            the spanName to set
	 */
	public void setSpanName(String spanName) {

		this.spanName = spanName;
	}
	
	/**
	 * @return the isSample
	 */
	public Boolean getIsSample() {
	
		return isSample;
	}

	
	/**
	 * @param isSample the isSample to set
	 */
	public void setIsSample(Boolean isSample) {
	
		this.isSample = isSample;
	}

	/**
	 * @return the serviceId
	 */
	public String getServiceId() {

		return serviceId;
	}

	/**
	 * @param serviceId
	 *            the serviceId to set
	 */
	public void setServiceId(String serviceId) {

		this.serviceId = serviceId;
	}

	/**
	 * @return the ts
	 */
	public long getTs() {

		return ts;
	}

	/**
	 * @param ts
	 *            the ts to set
	 */
	public void setTs(long ts) {

		this.ts = ts;
	}

	/**
	 * @return the location
	 */
	public Location getLocation() {
		if (location ==null) {
			location = new Location();
		}

		return location;
	}

	/**
	 * @param location
	 *            the location to set
	 */
	public void setLocation(Location location) {

		this.location = location;
	}

	/**
	 * @return the serialversionuid
	 */
	public static long getSerialversionuid() {

		return serialVersionUID;
	}

	/**
	 * @return the traceId
	 */
	public String getTraceId() {

		return traceId;
	}

	/**
	 * @param traceId
	 *            the traceId to set
	 */
	public void setTraceId(String traceId) {

		this.traceId = traceId;
	}

	/**
	 * @return the spanId
	 */
	public String getSpanId() {

		return spanId;
	}

	/**
	 * @param spanId
	 *            the spanId to set
	 */
	public void setSpanId(String spanId) {

		this.spanId = spanId;
	}

	/**
	 * @return the parentId
	 */
	public String getParentId() {

		return parentId;
	}

	/**
	 * @param parentId
	 *            the parentId to set
	 */
	public void setParentId(String parentId) {

		this.parentId = parentId;
	}

	/**
	 * @return the xmlyId
	 */
	public String getXmlyId() {

		return xmlyId;
	}

	/**
	 * @param xmlyId
	 *            the xmlyId to set
	 */
	public void setXmlyId(String xmlyId) {

		this.xmlyId = xmlyId;
	}

	/**
	 * @return the userId
	 */
	public String getUserId() {

		return userId;
	}

	/**
	 * @param userId
	 *            the userId to set
	 */
	public void setUserId(String userId) {

		this.userId = userId;
	}

	/**
	 * @return the deviceInfo
	 */
	public DeviceInfo getDeviceInfo() {
		if (deviceInfo ==null) {
			deviceInfo = new DeviceInfo();
		}

		return deviceInfo;
	}

	/**
	 * @param deviceInfo
	 *            the deviceInfo to set
	 */
	public void setDeviceInfo(DeviceInfo deviceInfo) {

		this.deviceInfo = deviceInfo;
	}

	/**
	 * @return the eventType
	 */
	public EventType getEventType() {

		return eventType;
	}

	/**
	 * @param eventType
	 *            the eventType to set
	 */
	public void setEventType(EventType eventType) {

		this.eventType = eventType;
	}

	/**
	 * @return the props
	 */
	public Map<String, String> getProps() {
		if (props ==null) {
			props = new HashMap<String, String>();
		}
		return props;
	}

	/**
	 * @param props
	 *            the props to set
	 */
	public void setProps(Map<String, String> props) {

		this.props = props;
	}

	public void addProp(String key, String value) {

		if (this.props == null) {
			this.props = new HashMap<String, String>();
		}
		this.props.put(key, value);
	}
	public void addBackProp(String key, String value) {

		if (this.abTestMap == null) {
			this.abTestMap = new HashMap<String, String>();
		}
		this.abTestMap.put(key, value);
	}
	public String getBackProp(String key) {
         if (abTestMap!=null) {
			return abTestMap.get(key);
		 }
         return null;
		
	}

	public String getBackId() {

		if (abTestMap != null) {
			Set<Map.Entry<String, String>> set = abTestMap.entrySet();
			StringBuffer sb = new StringBuffer();
			for (Map.Entry<String, String> entry : set) {
				String value = entry.getValue();
				sb.append(entry.getKey()).append(":");
				sb.append(value);
				sb.append("&");
			}
			return sb.toString();
		}

		return null;
	}

	public void putAllProp(Map<String, String> props) {

		if (this.props == null) {
			this.props = new HashMap<String, String>();
		}
		if (props != null) {
			this.props.putAll(props);
		}
	}

	/**
	 * @return the status
	 */
	public String getStatus() {

		return status;
	}

	/**
	 * @param status
	 *            the status to set
	 */
	public void setStatus(String status) {

		this.status = status;
	}

	public String getIp() {

		return ip;
	}

	public void setIp(String ip) {

		this.ip = ip;
	}

	public String getViewId() {

		return viewId;
	}

	public void setViewId(String viewId) {

		this.viewId = viewId;
	}

	public String getSeqId() {

		return seqId;
	}

	public void setSeqId(String seqId) {

		this.seqId = seqId;
	}

	public void addAnnotation(Annotation a) {

		if (annotations ==null) {
			annotations = new ArrayList<Annotation>();
		}
		annotations.add(a);
	}

	/**
	 * @return the annotations
	 */
	public List<Annotation> getAnnotations() {
		if (annotations ==null) {
			annotations = new ArrayList<Annotation>();
		}
		return annotations;
	}

	/**
	 * @param annotations
	 *            the annotations to set
	 */
	public void setAnnotations(List<Annotation> annotations) {

		this.annotations = annotations;
	}

	/**
	 * @return the spanType
	 */
	public SpanType getSpanType() {

		return spanType;
	}

	/**
	 * @param spanType
	 *            the spanType to set
	 */
	public void setSpanType(SpanType spanType) {

		this.spanType = spanType;
	}

	/**
	 * @return the binaryAnnotations
	 */
	public List<BinaryAnnotation> getBinaryAnnotations() {
		if (binaryAnnotations ==null) {
			binaryAnnotations = new ArrayList<BinaryAnnotation>();
		}
		return binaryAnnotations;
	}

	/**
	 * @param binaryAnnotations
	 *            the binaryAnnotations to set
	 */
	public void setBinaryAnnotations(List<BinaryAnnotation> binaryAnnotations) {

		this.binaryAnnotations = binaryAnnotations;
	}

	/**
	 * @return the monitorId
	 */
	public String getMonitorId() {

		return monitorId;
	}

	/**
	 * @param monitorId
	 *            the monitorId to set
	 */
	public void setMonitorId(String monitorId) {

		this.monitorId = monitorId;
	}

	/**
	 * @return the monitorPId
	 */
	public String getMonitorPId() {

		return monitorPId;
	}

	/**
	 * @param monitorPId
	 *            the monitorPId to set
	 */
	public void setMonitorPId(String monitorPId) {

		this.monitorPId = monitorPId;
	}

	/**
	 * @return the isRowData
	 */
	public Boolean getIsRowData() {

		return isRowData;
	}

	/**
	 * @param isRowData
	 *            the isRowData to set
	 */
	public void setIsRowData(Boolean isRowData) {

		this.isRowData = isRowData;
	}

	
	/**
	 * @return the personalType
	 */
	public String getPersonalType() {
	
		return personalType;
	}

	
	/**
	 * @param personalType the personalType to set
	 */
	public void setPersonalType(String personalType) {
	
		this.personalType = personalType;
	}

	
	/**
	 * @return the abTestMap
	 */
	public Map<String, String> getAbTestMap() {
	
		return abTestMap;
	}

	
	/**
	 * @param abTestMap the abTestMap to set
	 */
	public void setAbTestMap(Map<String, String> abTestMap) {
	
		this.abTestMap = abTestMap;
	}

	
	/**
	 * @return the personalApp
	 */
	public String getPersonalApp() {
	
		return personalApp;
	}

	
	/**
	 * @param personalApp the personalApp to set
	 */
	public void setPersonalApp(String personalApp) {
	
		this.personalApp = personalApp;
	}

	
	/**
	 * @return the clickMap
	 */
	public Map<String, Object> getClickMap() {
	
		return clickMap;
	}

	
	/**
	 * @param clickMap the clickMap to set
	 */
	public void setClickMap(Map<String, Object> clickMap) {
	
		this.clickMap = clickMap;
	}

	
	/**
	 * @return the url
	 */
	public String getUrl() {
	
		return url;
	}

	
	/**
	 * @param url the url to set
	 */
	public void setUrl(String url) {
	
		this.url = url;
	}

	public String getDetectAttrApp() {
		return detectAttrApp;
	}

	public void setDetectAttrApp(String detectAttrApp) {
		this.detectAttrApp = detectAttrApp;
	}

	public String getDetectAttrServiceId() {
		return detectAttrServiceId;
	}

	public void setDetectAttrServiceId(String detectAttrServiceId) {
		this.detectAttrServiceId = detectAttrServiceId;
	}

	public String getDetectAttrHost() {
		return detectAttrHost;
	}

	public void setDetectAttrHost(String detectAttrHost) {
		this.detectAttrHost = detectAttrHost;
	}

	
	
	

}
